package com.qmerak.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qmerak.dao.impl.MemSalvageDao;
import com.qmerak.dao.impl.MemberDao;
import com.qmerak.entity.MemberEntity;
import com.qmerak.entity.MemSalvageEntity;
import com.qmerak.service.IMemSalvageService;

/**
 * @author shaohong.cheng
 * @date 2013-7-2
 */
@Service
public class MemSalvageServiceImpl implements IMemSalvageService {
	@Autowired
	private MemSalvageDao salvageDao;
	@Autowired
	private MemberDao memberDao;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.qmerak.service.IMemberSalvageService#add(com.qmerak.entity.
	 * MemberSalvageEntity)
	 */
	@Override
	public MemSalvageEntity add(MemSalvageEntity salvageEntity) {
		MemSalvageEntity mse = salvageDao.add(salvageEntity);
		MemberEntity memberEntity = memberDao.find(salvageEntity.getMemberID());
		memberEntity.setSalvage(mse.getId());
		memberDao.update(memberEntity);
		return mse;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.qmerak.service.IMemberSalvageService#remove(com.qmerak.entity.
	 * MemberSalvageEntity)
	 */
	@Override
	public void remove(MemSalvageEntity salvageEntity) {
		salvageDao.remove(salvageEntity);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.qmerak.service.IMemberSalvageService#find(java.lang.String)
	 */
	@Override
	public MemSalvageEntity find(String id) {
		return salvageDao.find(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.qmerak.service.IMemberSalvageService#findUnapproveSalvages()
	 */
	@Override
	public List<MemSalvageEntity> findUnapproveSalvages() {
		return salvageDao.findUnapproveSalvages();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.qmerak.service.IMemberSalvageService#findUnfeedbackSalvages(com.qmerak
	 * .entity.MemberEntity)
	 */
	@Override
	public List<MemSalvageEntity> findUnfeedbackSalvages(
			MemberEntity memberEntity) {
		return salvageDao.findUnfeedbackSalvages(memberEntity);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.qmerak.service.IMemberSalvageService#findFeedbackedSalvages(com.qmerak
	 * .entity.MemberEntity)
	 */
	@Override
	public List<MemSalvageEntity> findFeedbackedSalvages(
			MemberEntity memberEntity) {
		return salvageDao.findFeedbackedSalvages(memberEntity);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.qmerak.service.IMemberSalvageService#updateState(com.qmerak.entity
	 * .MemberSalvageEntity, com.qmerak.entity.MemberEntity)
	 */
	@Override
	public void updateState(MemSalvageEntity salvageEntity,
			MemberEntity operater) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.qmerak.service.IMemSalvageService#findAppliedSalvages(com.qmerak.
	 * entity.MemberEntity)
	 */
	@Override
	public List<MemSalvageEntity> findAppliedSalvages(MemberEntity memberEntity) {
		return salvageDao.findAppliedSalvages(memberEntity);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.qmerak.service.IMemSalvageService#update(com.qmerak.entity.
	 * MemSalvageEntity)
	 */
	@Override
	public void update(MemSalvageEntity salvageEntity) {
		salvageDao.update(salvageEntity);
	}

}
